from flask import Flask, abort, redirect, render_template,request, url_for

app = Flask(__name__)

@app.route('/')
def home():
    return render_template('index.html')

@app.route('/login', methods=['GET', 'POST'])
def login():
    if request.method == 'POST':
        # 处理 POST 请求
        if request.form['username'] == 'admin' :
            return redirect(url_for('login_success'))
        else:
            return abort(401)
    else:
        # 处理 GET 请求
        return 'Please log in to access this page.'

@app.route('/login_success')
def login_success():
    return render_template('login_success.html')

if __name__ == '__main__':
    app.run(debug=True)